package org.hry.netty.protobuf;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.util.ReferenceCountUtil;

/**
 * @Desc
 * @Author houry
 * @Date 2021/2/20 15:43
 **/
public class ProtoBufServerHandler extends SimpleChannelInboundHandler<BarrageProto.Barrage> {



    @Override
    protected void channelRead0(ChannelHandlerContext ctx, BarrageProto.Barrage msg) throws Exception {
        System.out.println("进入了robot" + msg.toString());
        System.out.println("进入了robot" + msg.toBuilder().toString());
        if ("robot".equals(msg.getMsgType())) {
            System.out.println("robot--------" + msg);
        } else {
            ReferenceCountUtil.release(msg);
            ctx.fireChannelRead(msg);
        }
    }
}
